using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace App3._
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>

    public partial class Window1 : System.Windows.Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        public class DirtyFlag : DependencyObject
        {
            public DirtyFlag()
            {
            }

            public static bool ValidateData(object value)
            {
                return (bool)value == true || (bool)value == false;
            }

            public Nullable<bool> IsDirty
            {
                get { return _isDirty; }
                set { _isDirty = value; }
            }

            public static void SetIsDirty(DependencyObject obj, Nullable<bool> value)
            {
                obj.SetValue(IsDirtyProperty, value);
            }

            public static Nullable<bool> GetIsDirty(DependencyObject obj)
            {
                return (Nullable<bool>)obj.GetValue(IsDirtyProperty);
            }

            PropertyChangedCallback _callback;

            Nullable<bool> _isDirty = true;

            public static readonly DependencyProperty IsDirtyProperty =
            DependencyProperty.RegisterAttached("IsDirty", typeof(bool), typeof(DirtyFlag),
            new FrameworkPropertyMetadata(), new ValidateValueCallback(ValidateData));
        }
    }
}